const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: __dirname + "/src/client/main.tsx",
    output: {
        filename: "js/main.js",
        path: __dirname + "/dist/web/wwwroot"
    },

    // Enable sourcemaps for debugging webpack's output.
    devtool: "source-map",
    resolve: {
        extensions: [".ts", ".tsx", ".js", ".json", ".sass", ".scss", ".css"],
        modules: ["node_modules"]
    },

    module: {
        rules: [
            { test: /\.tsx?$/, loader: "ts-loader" },
            { enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
            {
                test: /\.scss$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader", options: { sourceMap: true } },
                    { loader: "sass-loader", options: { sourceMap: true } }]
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'Mini Othello',
            filename: 'main.html',
            template: __dirname + "/src/client/main.ejs",
            chunks: ['main']
        })
    ],
    externals: {
        "react": "React",
        "react-dom": "ReactDOM"
    },
};